<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<script type="text/javascript">
	    $(function() {
		$(".btn-ok").click(function() {
		    $.post("doSetPrivilege", $("form").serialize(), function(data) {
			helper.showMsg(data);
		    });
		});

		$(".btn-refresh").click(function() {
		    refreshPrivileges();
		});

		function refreshPrivileges() {
		    $("#scene").load("listPrivilege", {
			roleId : $("#roleId").val()
		    }, function() {
			$("input").change(function() {
			    var v = this.value;
			    v = v.replace(/\./g, "\\.");
			    var checked = this.checked;
			    $("#" + v).find("input").each(function() {
				this.checked = checked;
			    });

			    $(this).parent().next("ul").find("input").each(function() {
				this.checked = checked;
			    });
			});
		    });
		}

		refreshPrivileges();
	    });
	</script>
		<style type="text/css">
.privileges {
	border-collapse: collapse;
}

.privileges table {
	border-collapse: collapse;
}

.privileges td {
	padding: 0 1em 0 0;
}

.privileges ul {
	margin: 0.5em;
}

.privileges input {
	margin: 0.2em 0.5em;
}

.privileges h1,.privileges h2 {
	margin: 0.5em;
}

h1,h2 {
	font-size: 1em;
}

td {
	vertical-align: top;
}

td.catalog {
	
}

ul,li {
	margin: 0;
	padding: 0;
	list-style: none;
}

.odd {
	background: #fff;
}
</style>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<ul class="breadcrumb">
			<li><a href="../role/listRole">角色列表</a> <span class="divider">/</span></li>
			<li class="active">设置角色权限</li>
		</ul>
		<form>
			<div class="well well-small">
				<input type="hidden" name="roleId" id="roleId" value="${role.id}" />
				设置当前角色“${role.name}”的权限
				<a href="javascript:void(0)" class="btn btn-primary btn-ok">
					<i class="ico-ok ico-white"></i>保存
				</a>
				<a href="javascript:void(0)" class="btn btn-refresh">
					<i class="ico-repeat"></i> 刷新
				</a>
				<!-- <a href="javascript:void(0);" class="easyui-linkbutton btn-ok" iconCls="icon-ok">保存</a>
				<a href="javascript:void(0);" class="easyui-linkbutton btn-refresh" iconCls="icon-ok">刷新</a> -->
			</div>
			<div id="scene" class="v-indent"></div>
		</form>
	</tiles:putAttribute>
</tiles:insertDefinition>